/*
 * Function.cpp
 *
 *  Created on: 2011/06/11
 *      Author: naoki
 */

#include <time.h>
#include <pthread.h>
#include "NTEngine/Threading/Function.h"
namespace NTEngine {
namespace Threading {

void sleep( int ms ) {
	timespec req;
	if ( ms < 1000 ) {
		req.tv_sec = 0;
		req.tv_nsec = ms * 1000000;
	} else {
		req.tv_sec = ms / 1000;
		req.tv_nsec = ( ms % 1000 ) * 1000000;
	}
	nanosleep( &req, 0 );
}

unsigned getCurrentThreadId() {
	return static_cast< unsigned >( pthread_self() );
}

} // namespace Threading
} // namespace NTEngine
